package com.ming.service.impl;

import com.ming.dao.BusinessDao;
import com.ming.po.Business;
import com.ming.po.ResponseBean;
import com.ming.service.BusinessService;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BusinessServiceImpl implements BusinessService {

	@Autowired
	private BusinessDao bd;

	// 根据分类Id查询商家信息
	@Override
	public ResponseBean<List<Business>> listBusinessByOrderTypeId(Integer orderTypeId) {
		List<Business> list = null;
		ResponseBean<List<Business>> rb;
		list = bd.listBusinessByOrderTypeId(orderTypeId);

		if(list!=null && !list.isEmpty() ){
			rb = new ResponseBean<>(list);
		}else{
			rb = new ResponseBean<>(602,"商家信息不存在");
		}

		return rb;
	}

	// 根据商家Id查询商家信息
	@Override
	public ResponseBean<Business> getBusinessById(Integer businessId) {
		Business business = null;
		ResponseBean<Business> rb;
		business = bd.getBusinessById(businessId);

		if(business!=null){
			rb = new ResponseBean<>(business);
		}else{
			rb = new ResponseBean<>(602,"商家信息不存在");
		}

		return rb;
	}
}
